package com.taptech.doufu.ui.view.countdownview

/**
 * Created by Wyatt on 2018/3/19/019.
 */
object DateUtils{
    fun getDay(ms:Long):String{
        var day = (ms / (24 * 1000 * 60 * 60)).toInt()
        return "$day"
    }

    fun getHour(ms: Long): String {
        val hour = (ms / (1000 * 60 * 60)).toInt()
        if (hour > 9) {
            return hour.toString()
        }
        return "0$hour"
    }

    fun getMinute(ms: Long):String{
        val minute = (ms % (1000 * 60 * 60) / (1000 * 60)).toInt()
        if(minute > 9){
            return minute.toString()
        }
        return "0$minute"
    }
    fun getSecond(ms: Long):String{
        val second = (ms % (1000 * 60) / 1000).toInt()
        if(second > 9){
            return second.toString()
        }
        return "0$second"
    }
    fun getMillidecond(ms: Long):String{
        val millisecond = (ms % 1000).toInt()
        if(millisecond > 9){
            return millisecond.toString()
        }
        return "0$millisecond"
    }

    fun getDataString(ms: Long):String{
        var day = (ms / (24 * 1000 * 60 * 60)).toInt()
        var hour = ((ms % (24 * 1000 * 60 * 60)) / (1000 * 60 * 60)).toInt()
        return "${day}天 ${if (hour>9) "" else "0"}${hour} : ${getMinute(ms)} : ${getSecond(ms)}"
    }
}